/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pe.gob.fonafe.dao.impl.stored;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
import javax.sql.DataSource;
import oracle.jdbc.OracleTypes;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.SqlOutParameter;
import org.springframework.jdbc.object.StoredProcedure;
import pe.gob.fonafe.domain.BannerBean;

/**
 *
 * @author czela
 */
public class ObtenerBannerSP extends StoredProcedure{

    private static final String PROC_PARAM = "USERFINAL.P_OBT_BANNER";


    public ObtenerBannerSP(DataSource ds) {
        super(ds, PROC_PARAM);

        declareParameter(new SqlOutParameter("cCursor", OracleTypes.CURSOR,new ListarBannerRowMapper()));
        compile();
    }


    public Map execute() {
        Map inputs = new HashMap();
        return super.execute(inputs);
    }

    private static class ListarBannerRowMapper implements RowMapper<BannerBean>{

        public BannerBean mapRow(ResultSet rs, int rowNum) throws SQLException {
            BannerBean bean = new BannerBean();
            bean.setId(rs.getString("ID_BANNER"));
            bean.setAsunto(rs.getString("ASUNTO"));
            bean.setCuerpo(rs.getString("CUERPO"));
            bean.setInicio(rs.getDate("INICIO"));
            bean.setPeriodo(rs.getDate("PERIODO"));
            bean.setDisenio(rs.getString("DISENO"));
            return bean;
        }

    }



}
